package com.kfm.springboot.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kfm.springboot.domain.User;
import com.kfm.springboot.mapper.UserMapper;
import com.kfm.springboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper mapper;

    @Override
    public PageInfo<User> findAll(User user, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<User> users = mapper.selectAll(user);
        return new PageInfo<User>(users);
    }

    @Override
    public int remove(int id) {
        return mapper.deleteByPrimaryKey(id);
    }

}
